<?php

declare(strict_types=1);
/**
 * This file is part of MineAdmin.
 *
 * @link     https://www.mineadmin.com
 * @document https://doc.mineadmin.com
 * @contact  root@imoi.cn
 * @license  https://github.com/mineadmin/MineAdmin/blob/master/LICENSE
 */

namespace App\Model;

use Hyperf\Database\Model\Relations\BelongsTo;
use Hyperf\Database\Model\Relations\HasMany;
use Hyperf\DbConnection\Model\Model;

/**
 * App\Distributor
 *
 * @property int $id
 * @property int $charge_id 套餐id
 * @property float $fee 金额
 * @property int $minutes 分钟数
 * @property int $min_power 功率范围（小）
 * @property int $max_power 功率范围（大）
 * @property int $is_del 软删除
 * @property int $type 1=金额选项 2=功率时长分档设置 3=服务费分档设置
 * @property int $sort 排序
 */
class ChargeDetail extends Model
{
    public bool $timestamps = true;

    /**
     * The table associated with the model.
     */
    protected ?string $table = 'charge_detail';

    const POWER = 1;
    const FEE= 2;
    const SERVICE = 3;

    protected array $guarded = [];

    protected array $casts = [
        'created_at' => 'datetime:Y-m-d H:i:s',
        'updated_at' => 'datetime:Y-m-d H:i:s',
    ];

    /**套餐
     * @return BelongsTo
     */
    public function charge():BelongsTo{
        return $this->belongsTo(ChargeOption::class,'charge_option_id','id');
    }
}
